<?php
/* @var $this ProductController */
/* @var $model Product */
$this->breadcrumbs=array(
	'综合控制台'=>array($this->pre_module_url.'/index/index'),
	'产品管理'=>array($this->pre_module_url.'/productSale/admin'),
	'宝贝推荐'=>array($this->pre_module_url.'/product/recommend'),
	'编辑推荐信息',
);
?>
			<div class="recommend_box">
				<?php $form=$this->beginWidget('CActiveForm', array(
                    'id'=>'recommend-form',
                    'enableAjaxValidation'=>false,
                )); ?>
                <?php echo $form->hiddenField($model,'zpl_id',array('value'=>Yii::app()->request->getParam('id')));?>
            		<div class="hd mem_bgx">编辑推荐信息</div>
                    <ul class="form_list">
                        <li>
                            <img id="img1" style="width:100px" src="<?php echo !empty($model->zpl_pic)?$model->zpl_pic : '/images/cert_img.jpg' ;?>" alt="" />
                            <?php echo CHtml::link('上传缩略图<b class="mem_bgx left"></b><b class="mem_bgx right"></b>'.CHtml::fileField('image','',array('id'=>'uploadimg1','multiple'=>true)),'javascript:',array('class'=>'mem_bgx link_btn filelink mr20','onclick'=>"uploadimg('1')"))?>
                            <?php echo $form->hiddenField($model,'zpl_pic',array('id'=>'proimage1'))?>
                        </li>
                        <li>
                            <span class="tit"><?php echo $form->label($model,'zpl_title'); ?>：</span>
                            <?php echo $form->textField($model,'zpl_title',array('class'=>'t_ipt w_190','maxlength'=>'20')); ?>
                        </li>
                        <li>
                            <span class="tit"><?php echo $form->labelEx($model,'zpl_des'); ?>：</span>
                            <?php echo $form->textArea($model,'zpl_des'); ?>
                        </li>
                        <li>
                            <span class="tit"><?php echo $form->labelEx($model,'zpl_start_time'); ?>：</span>
                            <?php echo $form->textField($model,'zpl_start_time',array('class'=>'t_ipt w_120','maxlength'=>'20','onclick'=>"WdatePicker()")); ?>
                        </li>
                        <li>
                            <span class="tit"><?php echo $form->labelEx($model,'zpl_end_time'); ?>：</span>
                            <?php echo $form->textField($model,'zpl_end_time',array('class'=>'t_ipt w_120','maxlength'=>'20','onclick'=>"WdatePicker()")); ?>
                        </li>
                    </ul>
                    <div class="submit"><input class="mem_btn mem_btn18" type="submit" name="" value="保 存" /><input class="mem_btn mem_btn07" onclick="location.href=$this->pre_module_url.'/product/recommendproducts/zpoid/<?php echo $model->zpo_id;?>';" type="button" name="" value="返 回" /></div>
				<?php $this->endWidget(); ?>
            </div>
<script language="javascript" type="text/javascript" src="<?php echo Yii::app()->baseUrl;?>/js/My97DatePicker/WdatePicker.js"></script> 
<script src='<?php echo Yii::app()->baseUrl;?>/js/jquery.ui.widget.js'></script> 
<script src='<?php echo Yii::app()->baseUrl;?>/js/jquery.iframe-transport.js'></script> 
<script src='<?php echo Yii::app()->baseUrl;?>/js/jquery.fileupload.js'></script> 
<script type="text/javascript">
//上传图片
function uploadimg (id) {
     $('#uploadimg'+id).fileupload({          
          dataType: 'json',       
          url: '/Attachment/GetAjax',        
          success: function (json) {
                 if(json.upfile.errors=='1'){
                    alert(json.upfile.msg);
                 }else if(json.upfile.errors=='2'){
                    alert(json.upfile.msg);
                 }else{                   
                     //修改按钮图标
                   $('#img'+id).attr('src',json.upfile.file);
             //修改按钮文本
                   $('#uploadimg'+id).parent().html('修改图片<b class="mem_bgx left"></b><b class="mem_bgx right"></b><input type="file" id="uploadimg'+id+'" multiple name="image"/>');
                   //填加删除按钮
                   if(!$('#img'+id).parent().parent().find('a')[1]){
                     $('#img'+id).parent().parent().find('a').eq(0).after('<a class="mem_bgx link_btn" href="javascript:" onclick="removeimg(\''+id+'\')">删除图片<b class="mem_bgx left"></b><b class="mem_bgx right"></b></a>');
                   }
             //修改隐藏域值
                     $('#proimage'+id).attr('value',json.upfile.file);
                 }  
          }
      });
};
//删除图片
function removeimg(id){
  $('#img'+id).parent().parent().find('a').eq(0).html('上传图片<b class="mem_bgx left"></b><b class="mem_bgx right"></b><input type="file" id="uploadimg'+id+'" multiple name="image"/>');
  $('#img'+id).parent().parent().find('a').eq(1).remove();
  $('#img'+id).attr('src','/images/cert_img.jpg');
  $('#proimage'+id).attr('value','');
}		
 </script>